
from atm.conf import setting
import logging
import os


def atm_log(msg: str, level: int):

    if not os.path.exists(setting.DB_ATM_LOG_PATH):
        file = open(setting.DB_ATM_LOG_PATH, "w")
        file.close()

    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                        datefmt='%Y/%m/%d %H:%M:%S', filename=setting.DB_ATM_LOG_PATH, filemode='a')
    if level == 1:
        logging.info(msg)
    elif level == 2:
        logging.debug(msg)
    elif level == 3:
        logging.warning(msg)
    elif level == 4:
        logging.error(msg)
    elif level == 5:
        logging.critical(msg)


def consume_log(msg: str, level: int):

    if not os.path.exists(setting.DB_CONSUME_LOG_PATH):
        file = open(setting.DB_CONSUME_LOG_PATH, "w")
        file.close()

    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                        datefmt='%Y/%m/%d %H:%M:%S', filename=setting.DB_COMSUME_LOG_PATH, filemode='a')
    if level == 1:
        logging.info(msg)
    elif level == 2:
        logging.debug(msg)
    elif level == 3:
        logging.warning(msg)
    elif level == 4:
        logging.error(msg)
    elif level == 5:
        logging.critical(msg)
